<?php

namespace App\Controller\Api\Wuliu;

use App\Base\BaseController4Restful;
use App\Entity\Wuliu\WuliuCars;
use App\Event\PayEvent;
use App\EventSubscriber\Wuliu\PaySubscriber;
use App\Repository\Wuliu\WuliuCarsRepository;
use App\Service\PayService;
use App\Service\Wechat\WechatPay;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class ApiWuliuPayController extends BaseController4Restful
{
    /**
     * @Route("/api/wuliuPay/create", name="apiGetWuliuPayCreate",methods={"GET","POST"})
     */
    public function apiGetWuliuPayCreate(
        WechatPay $wechatPay,
        PayService $payService
    )
    {
        $user = $this->needToBeUser();
        $money = 1200;
        $payOrder = $payService->createPayOrder($user,$money,null,null,null,[PaySubscriber::EventFlag]);
        $money = $payOrder->getMoney()*100;
        $money = 2;//todo 上线修改
        $data = $wechatPay->createOrder($user->getOpenid(),"会员升级",$payOrder->getSn(),$money,"charge");
        return $this->json_out(1,"OK",$data);
    }
}
